How do I fix unexpected error in copying a file